import 'package:wanxiang_app/generated/json/base/json_convert_content.dart';
import 'package:wanxiang_app/bean/tousu_entity.dart';

TousuEntity $TousuEntityFromJson(Map<String, dynamic> json) {
  final TousuEntity tousuEntity = TousuEntity();
  final int? code = jsonConvert.convert<int>(json['code']);
  if (code != null) {
    tousuEntity.code = code;
  }
  final String? msg = jsonConvert.convert<String>(json['msg']);
  if (msg != null) {
    tousuEntity.msg = msg;
  }
  final List<TousuData>? data = (json['data'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<TousuData>(e) as TousuData).toList();
  if (data != null) {
    tousuEntity.data = data;
  }
  return tousuEntity;
}

Map<String, dynamic> $TousuEntityToJson(TousuEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['code'] = entity.code;
  data['msg'] = entity.msg;
  data['data'] = entity.data.map((v) => v.toJson()).toList();
  return data;
}

extension TousuEntityExtension on TousuEntity {
  TousuEntity copyWith({
    int? code,
    String? msg,
    List<TousuData>? data,
  }) {
    return TousuEntity()
      ..code = code ?? this.code
      ..msg = msg ?? this.msg
      ..data = data ?? this.data;
  }
}

TousuData $TousuDataFromJson(Map<String, dynamic> json) {
  final TousuData tousuData = TousuData();
  final String? title = jsonConvert.convert<String>(json['title']);
  if (title != null) {
    tousuData.title = title;
  }
  final String? content = jsonConvert.convert<String>(json['content']);
  if (content != null) {
    tousuData.content = content;
  }
  return tousuData;
}

Map<String, dynamic> $TousuDataToJson(TousuData entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['title'] = entity.title;
  data['content'] = entity.content;
  return data;
}

extension TousuDataExtension on TousuData {
  TousuData copyWith({
    String? title,
    String? content,
  }) {
    return TousuData()
      ..title = title ?? this.title
      ..content = content ?? this.content;
  }
}